package pj.pamper.clw.mvp.presenter;


import com.example.framelib.entity.VersionEntity;
import com.example.framelib.mvp.frame.ActivityPresenter;
import com.example.framelib.rx.FilterSubscriber;

import java.io.File;
import java.util.List;

import pj.pamper.clw.mvp.contract.MainContract;
import pj.pamper.clw.mvp.model.MainModel;

/**
 * Created by zhang on 2017/4/5.
 */

public class MainPresenter extends ActivityPresenter<MainModel,MainContract.View> implements MainContract.Presenter{
    public static final String TAG = "MainPresenter";

    @Override
    public void add(String reportType, List<File> images, String reportDesc, File voice, String tel) {
        addSubscription(getModel().add(reportType, images, reportDesc,voice, tel), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().showError(errorMsg);
            }

            @Override
            public void onNext(Object mO) {
                getView().showSuccess();
            }
        });
    }

    @Override
    public void checkVersion() {
        addSubscription(getModel().checkVersion(), new FilterSubscriber<VersionEntity>() {
            @Override
            public void onNext(VersionEntity mVersionEntity) {
                getView().showVersion(mVersionEntity);
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().showError(errorMsg);
            }

        });
    }
}
